home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #14
/
Monster Media No. 14 (April 1996) (Monster Media, Inc.).ISO
/
prog_gen
/
instal11.zip
/
DIALUN.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-01-11
|
5KB
|
189 lines
unit Dialun;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, ExtCtrls, Buttons, DdeMan;
type
TDialUninstall = class(TForm)
btUnInst: TBitBtn;
btStop: TBitBtn;
Mem_Desc: TMemo;
Bevel1: TBevel;
Bevel2: TBevel;
Tit_Desc: TLabel;
Label2: TLabel;
DdeClient: TDdeClientConv;
procedure btStopClick(Sender: TObject);
procedure Initialise(Sender: TObject);
procedure btUnInstClick(Sender: TObject);
private
{ Private-dΘclarations }
First : boolean;
function DestroyGroup (FileName : string) : integer;
public
{ Public-dΘclarations }
end;
var
DialUninstall: TDialUninstall;
implementation
uses Decla,Disque,Lecture,UnAbout;
{$R *.DFM}
(* Destroy programs group *)
function TDialUninstall.DestroyGroup (FileName : string) : integer;
var Tmp : integer;
Macro : string;
Cmd : array [0 .. 255] of Char;
begin
Tmp := 0;
if FileName = '' then
Tmp := 1
else
begin
Macro := Format('[DeleteGroup(%s)]', [FileName]) + #13#10;
StrPCopy (Cmd, Macro);
DDEClient.ConnectMode := DDEAutomatic;
if DDEClient.SetLink('Progman','Progman') = true then
begin
if not DDEClient.ExecuteMacro(Cmd, False) then
Tmp := 2;
DDEClient.CloseLink;
end
else
Tmp := 3;
end;
DestroyGroup := Tmp;
end;
(* initialisation *)
procedure TDialUninstall.Initialise(Sender: TObject);
begin
Error := -1;
First := true;
Tit_Desc.Enabled := false;
Mem_Desc.Enabled := false;
ActiveControl := btUnInst;
end;
(* UnInstall button *)
procedure TDialUninstall.btUnInstClick(Sender: TObject);
var Tmp : integer;
Ite : integer;
Tp1 : integer;
begin
Mem_Desc.Lines.Add ('UnInstall is starting ...');
btUnInst.Enabled := false;
Tmp := ReadUnsFile;
if Tmp = 0 then
begin
btUnInst.Enabled := false;
(* how many lines ? *)
Tp1 := 0; Ite := 0;
while Tp1 < Max_Unin do
begin
Inc (Tp1);
If VUnins [Tp1].TypeCase <> -1 then
Ite := Tp1
end;
(* Begin uninstall *)
while Ite > 0 do
begin
Case VUnins [Ite].TypeCase of
0 : (* directory *)
begin
Mem_Desc.Lines.Add ('Deleting Uninstall application');
DeleteFile (VUnins [Ite].FullName + '\' + Fch_UnIns + 'INS');
DeleteFile (VUnins [Ite].FullName + '\' + Fch_UnIns + 'EXE');
Mem_Desc.Lines.Add ('Deleting directory ' + VUnins [Ite].FullName);
if DestroyDirectory (VUnins [Ite].FullName) <> 0 then
(* unable to destroy *)
Tmp := 1;
end;
1 : (* files *)
begin
Mem_Desc.Lines.Add ('Deleting file ' + VUnins [Ite].FullName);
if DeleteFile (VUnins [Ite].FullName) <> 0 then
(* unable to destroy *)
Tmp := 2;
end;
2 : (* group *)
begin
Mem_Desc.Lines.Add ('Deleting group ' + VUnins [Ite].FullName);
if DestroyGroup (VUnins [Ite].FullName) <> 0 then
(* unable to destroy *)
Tmp := 3;
end;
else
(* wrong parameter *)
Tmp := 4;
end;
Dec (Ite);
end;
end
else
(* error during read of unistall file *)
Tmp := Tmp + 4;
Error := Tmp;
btUnInst.Enabled := True;
Mem_Desc.Enabled := true;
First := false;
Mem_Desc.Lines.Add ('Uninstall is ended');
btStopClick (Sender);
end;
(* button Stop *)
procedure TDialUninstall.btStopClick(Sender: TObject);
var Tmp : string;
begin
if (Error = -1) and (btUnInst.Enabled = true) then
Close
else
begin
if btUnInst.Enabled = true then
begin
If error = 0 then
begin
Mem_Desc.Lines.Add ('UnInstall is successfull');
Final.ShowModal;
Close;
end
else
begin
Mem_Desc.Lines.Add ('UnInstall is unsuccessfull');
case Error of
1 : tmp := 'because unable to delete directory';
2 : tmp := 'because unable to delete file';
3 : tmp := 'because unable to delete group';
4 : tmp := 'because bad parameter on UnInstall file';
5 : tmp := 'because uninstall file (UNSETUP.INS) doesn''t exist';
6 : tmp := 'because unable to read line on unistall file';
7 : tmp := 'because not a number on line';
8 : tmp := 'because maximum of files reach';
9 : tmp := 'because wrong number in line';
end;
Mem_Desc.Lines.add (Tmp);
btUnInst.Enabled := false;
end;
end
else
begin
if Error <> 0 then
Close;
Mem_Desc.Lines.Add ('UnInstall cancelled by user');
btUnInst.Enabled := true;
end;
end;
end;
end.